public class Test012 {
    public static void main(String[] args) {
        System.out.println(fac(18, 24));
    }
        public static int fac (int a,int b){
            int c = a % b;
            while (c != 0) {
                a = b;
                b = c;
                c = a % b;
            }
            return b;
    }
}
